home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’95 / What's On My Mac / MemoryUtil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-24  |  611 b   |  60 lines  |  [TEXT/MMCC]

  1. /*****
  2.  *
  3.  *    MemoryUtil.c
  4.  *
  5.  *****/
  6.  
  7. #include "MemoryUtil.h"
  8.  
  9.  
  10. Handle
  11. MyNewHandleClear ( long theSize, OSErr *theErr )
  12. {
  13.     Handle    theHandle;
  14.     OSErr    myErr;
  15.     
  16.     theHandle    = NewHandleClear ( theSize );
  17.     myErr        = MemError ();
  18.     
  19.     if ( *theErr != nil )
  20.     {
  21.         *theErr = myErr;
  22.     }
  23.     
  24.     if ( myErr != noErr )
  25.     {
  26.         return nil;
  27.     }
  28.     else
  29.     {
  30.         return theHandle;
  31.     }
  32. }
  33.  
  34.  
  35. Ptr
  36. MyNewPtr ( long theSize, OSErr *theErr )
  37. {
  38.     Ptr        thePtr;
  39.     OSErr    myErr;
  40.     
  41.     thePtr        = NewPtr ( theSize );
  42.     myErr        = MemError ();
  43.     
  44.     if ( *theErr != nil )
  45.     {
  46.         *theErr = myErr;
  47.     }
  48.     
  49.     if ( myErr != noErr )
  50.     {
  51.         return nil;
  52.     }
  53.     else
  54.     {
  55.         return thePtr;
  56.     }
  57. }
  58.  
  59.  
  60.